/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.bluesbruce.so;

import com.sun.jna.Library;
import com.sun.jna.Native;

/**
 * 通过JNA调用SO文件
 * <pre>
 * so文件的搜索路径
 * 1. 可以通过设置系统属性“jna.library.path”
 * 2. 修改系统的库访问环境变量
 * 3. 将库放置在classpath下，或者放在{OS}-{ARCH}/目录下，
 * 比如win32-x86，win32-x86-64，linux-x86-64，linux-x86，linux-amd64，darwin等。
 * 如果放在jar文件中，则会在加载时自动提取。
 * </pre>
 * <pre>
 * so文件名规则
 * 1. 用文件全名XXXX.so
 * 2. 用部分文件名XXXX，但文件全名的规格必须是libXXXX.so（仅限于classpath模式）
 * </pre>
 * @author BBF
 */
public interface RunSo extends Library {

  RunSo INSTANCE = Native.load(GetLibraryPathHelper.GetLibPath(), RunSo.class);

  int add(int a, int b);

  class GetLibraryPathHelper {

    // can replaced by absolute path
    public static String GetLibPath() {
      return "/hty_web/libAdd.so";
    }
  }
}
